package com.anzia.reader;

import java.io.FileReader;
import java.io.FileWriter;

/**
 *@ClassName Copy_Demo
 *@Description 使用FileReader和FileWriter复制文本文件，不能复制图片或二进制文件
 *@Author Anzia.
 *@Date 2021/4/9 16:06
 *@Version 1.0
 **/
public class Copy_Demo {
    public static void main(String[] args) throws Exception {
        //创建FileReader和FileWriter
        FileReader fr = new FileReader("static\\write.txt");
        FileWriter fw = new FileWriter("static\\write2.txt");

        //读写
        int data = 0;
        while ((data = fr.read()) != -1) {
            fw.write(data);
            fw.flush();
        }

        //关闭
        fr.close();
        fw.close();
        System.out.println("执行成功！");
    }
}
